package io.yuncheng.modules.sys.entity;

import com.alibaba.fastjson.JSON;
import io.yuncheng.common.utils.Constant;
import io.yuncheng.common.utils.R;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 *
 * 日志接口
 * @Author shouxu
 * @Date 2020/11/25 15:25
 */
@Data
public class AgentArithmeticLogEntity {
    Date logDate;
    String appId;
    String transactionId;
    List<AgentArithmeticStepEntity>  steps;
    Long timeSpan;

    public SubAppLogEntity buildByLogEntity(){
        SubAppLogEntity subAppLogEntity = new SubAppLogEntity();
        subAppLogEntity.setSteps(JSON.toJSONString(this.getSteps()));
        subAppLogEntity.setExeTime(this.getTimeSpan());
        subAppLogEntity.setTransactionId(this.getTransactionId());
        subAppLogEntity.setAppUniqueId(this.getAppId());
        subAppLogEntity.setLogDate(this.getLogDate());
        subAppLogEntity.setLogType("");
        subAppLogEntity.setActionParameters("");
        subAppLogEntity.setCreateDate(new Date());
        subAppLogEntity.setLogStatus(Constant.StatusType.NORMAL.getValue()+"");
        subAppLogEntity.setLogStatusMsg("");
        return subAppLogEntity;
    }

    public static void main(String[] args) {
        AgentArithmeticLogEntity ag = new AgentArithmeticLogEntity();
        ag.setAppId("appId");
        List<AgentArithmeticStepEntity> list = new ArrayList<>();
        AgentArithmeticStepEntity age = new AgentArithmeticStepEntity();
        age.setStepId(1);
        age.setStepAlgo("SM2");
        age.setStepHost("Sig");
        age.setStepContent("content");
        age.setStepResult("Success");
        age.setStepTimeSpan(1L);
        list.add(age);

        ag.setSteps(list);
        ag.setTransactionId("054ad8c7-c643-4a66-bc6c-1012e53e28e3");
        ag.setTimeSpan(10L);
        System.out.println(JSON.toJSONString(R.ok()));

    }

}
